Loading
Scriptbox
 VBScript Links 
 About VBscript 
 JavaScript Links 
 About JavaScript 
 Powershell Links 
 PSCRIPT the Script Launcher 
 PowerShell Shortcut Keys 
 About Powershell 
     VBScript
    JavaScript
    Powershell
Disclaimer
Contact
Latest 10 Scripts
Script search
  :: { Category } :: 0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ
         

Search Options:  Determine  ProcessID  (PID)  of  the  running  Script  

 Content of Determine ProcessID (PID) of the running Script.vbs
MD5 Hash: 48DC58735728279D543F61AE8E9DC9D4
Dim strComputer : strComputer = "."
Dim oWMIService : Set oWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim colItems : Set colItems = oWMIService.ExecQuery("Select * From Win32_Process")
Dim sScriptCommandLine : sScriptCommandLine = wscript.ScriptFullName
Dim dStartTime : dStartTime = Now
Dim sScriptHostPath : sScriptHostPath = WScript.FullName


For Each oItem in colItems
If InStr(oItem.CommandLine, sScriptCommandLine) > 0 and InStr(oItem.CommandLine, sScriptHostPath) > 0 Then
'Wscript.Echo oItem.CommandLine
dProcessStartTime = oItem.CreationDate
dProcessStartTime = DateSerial(Left(dProcessStartTime, 4), Mid(dProcessStartTime, 5, 2), Mid(dProcessStartTime, 7, 2) ) + TimeSerial(Mid(dProcessStartTime, 9, 2), Mid(dProcessStartTime, 11, 2), Mid(dProcessStartTime, 13, 2))
dStartDateDiff = DateDiff("s", dStartTime, dProcessStartTime)

Select Case dStartDateDiff

Case 0, -1, 1
Wscript.Echo oItem.ProcessID
End Select

End If
Next

   © 2008 - 2013 Boris Toll      :: Scripts available: 6.481 ::      :: scriptbox.toll.at ::      :: powered by www.toll.at ::
  Google Entries:n/a
  Yahoo Backlinks:n/a
  Live Backlinks:n/a
  del.icio.us Bookmarks:n/a
  Technorati Links:n/a